from sqlalchemy import CheckConstraint
from sqlalchemy.orm import Mapped, mapped_column, relationship
from database.models.base import str_256, created_at, updated_at, Base


class PhysicalActivity(Base):
    __tablename__ = "physical_activities"
    
    name: Mapped[str_256] = mapped_column(primary_key=True)
    coef: Mapped[float]
    
    created_at: Mapped[created_at]
    updated_at: Mapped[updated_at]
    
    users: Mapped[list["User"]] = relationship(  # noqa: F821
        back_populates="physical_activity",
    )
    
    __table_args__ = (
        CheckConstraint("coef > 0", name="check_coef_positive"),
    )